package com.onLoading;

import javafx.concurrent.Task;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Pagination;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;

import java.net.URL;
import java.util.ResourceBundle;

public class ProfileController implements Initializable {
    @FXML
    private Pagination pagination;
    private Image[] images = new Image[3];

    public ProfileController() {
    }

    public void initialize(URL url, ResourceBundle rb) {
        this.images[0] = new Image(this.getClass().getResourceAsStream("1.png"));
        this.images[1] = new Image(this.getClass().getResourceAsStream("2.png"));
        this.images[2] = new Image(this.getClass().getResourceAsStream("3.png"));
        this.pagination.setPageFactory((pageIndex) -> {
            return this.createAnimalPage(pageIndex);
        });
        };
//        Thread t = new Thread(task);
//        t.setDaemon(true);
//        t.start();
//    }

    private VBox createAnimalPage(int pageIndex) {
        VBox box = new VBox();
        ImageView iv = new ImageView(this.images[pageIndex]);
        box.setAlignment(Pos.CENTER);
        box.getChildren().addAll(new Node[]{iv});
        return box;
    }
}